package cn.ichiva.puppet.example.base.p2;

import javafx.beans.property.StringProperty;
import javafx.fxml.FXML;
import javafx.fxml.impl.AbstractPuppetComponent;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;

import java.util.Map;

/**
 * 带标签的输入框
 */
public class L1P1LabelTextField extends AbstractPuppetComponent {
    @FXML
    StringProperty labelText;
    @FXML
    StringProperty fieldText;

    @Override
    public CharSequence render() {
        imports(Pane.class, Label.class, TextField.class);
        return """
                <Pane>
                    <Label text="${labelText}"  />
                    <TextField text="${fieldText}" />
                </Pane>
                """;
    }

    @Override
    public void setProps(Map<String, Object> props) {
        super.setProps(props);

        this.labelText = (StringProperty) props.get("labelText");
        this.fieldText = (StringProperty) props.get("fieldText");
    }
}
